package com.noname.lib_base_java.net;

import android.text.TextUtils;

/**
 * Author: Lmoumou
 * Date: 2018-12-10 12:13
 * 文件名: NetManager
 * 描述:网络请求配置单
 */
public final class NetManager {

    //Api地址
    private static String baseUrl = "";
    //图片上传地址
    private static String resUrl = "";
    //图片上传域
    private static String areaFiel = "";


    public String getBaseUrl() {
        return baseUrl;
    }

    public String getResUrl() {
        return resUrl;
    }

    public String getAreaFiel() {
        return areaFiel;
    }


    private static NetManager instance = null;

    public static NetManager getInstance() {

        if (TextUtils.isEmpty(baseUrl)) {
            throw new RuntimeException("未初始化Api地址");
        }
        if (TextUtils.isEmpty(resUrl)) {
            throw new RuntimeException("未初始化图片上传地址");
        }
        if (TextUtils.isEmpty(areaFiel)) {
            throw new RuntimeException("未初始化图片上传域");
        }

        if (instance == null) {
            synchronized (NetManager.class) {
                instance = new NetManager();
            }
        }
        return instance;
    }

    /**
     * 初始化
     */
    public static void init(String baseUrl, String resUrl, String areaFiel) {
        NetManager.baseUrl = baseUrl;
        NetManager.resUrl = resUrl;
        NetManager.areaFiel = areaFiel;

    }

}
